// 导入请求实例

import axios from "./request.js"

export function fetchLunbo() {
    return axios.get('/getlunbo')
}

export function fetchRecommend(page = 1, limit = 10) {
    return axios.get(`/recommend?page=${page}&limit=${limit}`)
}

export function fetchGoodsList(page = 1, limit = 10) {
    return axios.get(`/getgoods?pageindex=${page}&pagesize=${limit}`)
}


export function fetchNewsList(page = 1, limit = 6) {
    return axios.get(`/getnewslist?page=${page}&pagesize=${limit}`)
}

export function fetchNewsDetail(newid) {
    return axios.get(`/getnew/${newid}`)
}

///getcomments/13?pageindex=1
export function fetchNewsComment(newid, page = 1) {
    return axios.get(`/getcomments/${newid}?pageindex=${page}`)
}

// 发布评论
export function fetchPostComment(newid, content) {
    return axios.post(`/postcomment/${newid}`, {
        content
    })
}

// 获取商品的轮播图
export function fetchGoodsImages(goodsid) {
    return axios.get(`/getthumbimages/${goodsid}`)
}

// 获取商品的基本信息
export function fetchGoodsInfo(goodsid) {
    return axios.get(`/getgoodsinfo/${goodsid}`)
}

// 商品搜索接口
// search?value=i&sort=buy&page=1&pagesize=10
export function fetchSearchGoods(options) {
    let {
        value,
        sort,
        order,
        page,
        pagesize
    } = options;
    return axios.get(`/search?value=${value}&sort=${sort}&order=${order}&page=${page}&pagesize=${pagesize}`)
}

// 获取购物车商品列表
export function fetchCartGoods(ids) {
    return axios.get(`/getshopcarlist/${ids}`)
}
